//
//  ListViewController.m
//  SELF 豆瓣
//
//  Created by dllo on 15/11/7.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "ListViewController.h"
#import "MovieListViewController.h"
#import "FlowLayoutController.h"
#import "pass.h"
@interface ListViewController ()
@property(nonatomic,retain)MovieListViewController *movlist;
@property(nonatomic,retain)FlowLayoutController *puVC;
@property(nonatomic,retain)UIButton *button;
@property(nonatomic,assign)BOOL isSelected;
@end


@implementation ListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.view.backgroundColor = [UIColor grayColor];
    self.button = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    self.button.frame = CGRectMake(0, 0, 40, 43);
    [self.button setImage:[UIImage imageNamed:@"btn_nav_list@2x.png"] forState:UIControlStateNormal];

    
    [self.button setTitleColor:[UIColor colorWithRed:0.322 green:0.562 blue:0.249 alpha:1.000] forState:UIControlStateNormal];
    self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc]initWithCustomView:self.button]autorelease];
    self.isSelected = NO;
    
    self.puVC = [[FlowLayoutController alloc]init];
    [self addChildViewController:self.puVC];
    [self.view addSubview:self.puVC.view];
    [_puVC release];
    
    
    
    
    self.movlist = [[MovieListViewController alloc]init];
    [self addChildViewController:self.movlist];
    [self.view addSubview:self.movlist.view];
    [_movlist release];
    
    
    
    
    
}

-(void)buttonAction:(UIButton *)btn
{
    if (self.isSelected == NO) {
        [self.button setImage:[UIImage imageNamed:@"btn_nav_collection@2x.png"] forState:UIControlStateNormal];
        //        [self.view bringSubviewToFront:self.listVC.view];
        [UIView  transitionFromView:self.movlist.view toView:self.puVC.view duration:0.5 options:UIViewAnimationOptionTransitionFlipFromRight completion:^(BOOL finished) {
            
            
        }];
        
        
    }
    else
    {
        [self.button setImage:[UIImage imageNamed:@"btn_nav_list@2x.png"] forState:UIControlStateNormal];
        [UIView  transitionFromView:self.puVC.view toView:self.movlist.view duration:0.5 options:UIViewAnimationOptionTransitionFlipFromLeft completion:^(BOOL finished) {
            
            
        }];
        
        
        
    }
    self.isSelected = !self.isSelected;
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
